"use strict";(()=>{var z,h,E,X,M,Y=-1,m=function(e){addEventListener("pageshow",function(t){t.persisted&&(Y=t.timeStamp,e(t))},!0)},H=function(){var e=self.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart=0?r="back-forward-cache":n&&(document.prerendering||D()>0?r="prerender":document.wasDiscarded?r="restore":n.type&&(r=n.type.replace(/_/g,"-"))),{name:e,value:t===void 0?-1:t,rating:"good",delta:0,entries:[],id:"v4-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:r}},g=function(e,t,n){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){var r=new PerformanceObserver(function(i){Promise.resolve().then(function(){t(i.getEntries())})});return r.observe(Object.assign({type:e,buffered:!0},n||{})),r}}catch(i){}},f=function(e,t,n,r){var i,a;return function(s){t.value>=0&&(s||r)&&((a=t.value-(i||0))||i===void 0)&&(i=t.value,t.delta=a,t.rating=function(c,o){return c>o[1]?"poor":c>o[0]?"needs-improvement":"good"}(t.value,n),e(t))}},R=function(e){requestAnimationFrame(function(){return requestAnimationFrame(function(){return e()})})},C=function(e){document.addEventListener("visibilitychange",function(){document.visibilityState==="hidden"&&e()})},x=function(e){var t=!1;return function(){t||(e(),t=!0)}},v=-1,O=function(){return document.visibilityState!=="hidden"||document.prerendering?1/0:0},F=function(e){document.visibilityState==="hidden"&&v>-1&&(v=e.type==="visibilitychange"?e.timeStamp:0,pe())},j=function(){addEventListener("visibilitychange",F,!0),addEventListener("prerenderingchange",F,!0)},pe=function(){removeEventListener("visibilitychange",F,!0),removeEventListener("prerenderingchange",F,!0)},V=function(){return v<0&&(v=O(),j(),m(function(){setTimeout(function(){v=O(),j()},0)})),{get firstHiddenTime(){return v}}},w=function(e){document.prerendering?addEventListener("prerenderingchange",function(){return e()},!0):e()},q=[1800,3e3],W=function(e,t){t=t||{},w(function(){var n,r=V(),i=u("FCP"),a=g("paint",function(s){s.forEach(function(c){c.name==="first-contentful-paint"&&(a.disconnect(),c.startTimer.value&&(r.value=i,r.entries=a,n())},c=g("layout-shift",s);c&&(n=f(e,r,_,t.reportAllChanges),C(function(){s(c.takeRecords()),n(!0)}),m(function(){i=0,r=u("CLS",0),n=f(e,r,_,t.reportAllChanges),R(function(){return n()})}),setTimeout(n,0))}))},$=0,k=1/0,P=0,he=function(e){e.forEach(function(t){t.interactionId&&(k=Math.min(k,t.interactionId),P=Math.max(P,t.interactionId),$=P?(P-k)/7+1:0)})},ee=function(){return z?$:performance.interactionCount||0},me=function(){"interactionCount"in performance||z||(z=g("event",he,{type:"event",buffered:!0,durationThreshold:0}))},l=[],A=new Map,te=0,ve=function(){var e=Math.min(l.length-1,Math.floor((ee()-te)/50));return l[e]},ge=[],ye=function(e){if(ge.forEach(function(i){return i(e)}),e.interactionId||e.entryType==="first-input"){var t=l[l.length-1],n=A.get(e.interactionId);if(n||l.length<10||e.duration>t.latency){if(n)e.duration>n.latency?(n.entries=[e],n.latency=e.duration):e.duration===n.latency&&e.startTime===n.entries[0].startTime&&n.entries.push(e);else{var r={id:e.interactionId,latency:e.duration,entries:[e]};A.set(r.id,r),l.push(r)}l.sort(function(i,a){return a.latency-i.latency}),l.length>10&&l.splice(10).forEach(function(i){return A.delete(i.id)})}}},ne=function(e){var t=self.requestIdleCallback||self.setTimeout,n=-1;return e=x(e),document.visibilityState==="hidden"?e():(n=t(e),C(e)),n},J=[200,500],ie=function(e,t){"PerformanceEventTiming"in self&&"interactionId"in PerformanceEventTiming.prototype&&(t=t||{},w(function(){var n;me();var r,i=u("INP"),a=function(c){ne(function(){c.forEach(ye);var o=ve();o&&o.latency!==i.value&&(i.value=o.latency,i.entries=o.entries,r())})},s=g("event",a,{durationThreshold:(n=t.durationThreshold)!==null&&n!==void 0?n:40});r=f(e,i,J,t.reportAllChanges),s&&(s.observe({type:"first-input",buffered:!0}),C(function(){a(s.takeRecords()),r(!0)}),m(function(){te=ee(),l.length=0,A.clear(),i=u("INP"),r=f(e,i,J,t.reportAllChanges)}))}))},Q=[2500,4e3],N={},re=function(e,t){t=t||{},w(function(){var n,r=V(),i=u("LCP"),a=function(o){t.reportAllChanges||(o=o.slice(-1)),o.forEach(function(d){d.startTime=0&&E1e12?new Date:performance.now())-e.timeStamp;e.type=="pointerdown"?function(n,r){var i=function(){G(n,r),s()},a=function(){s()},s=function(){removeEventListener("pointerup",i,T),removeEventListener("pointercancel",a,T)};addEventListener("pointerup",i,T),addEventListener("pointercancel",a,T)}(t,e):G(t,e)}},se=function(e){["mousedown","keydown","touchstart","pointerdown"].forEach(function(t){return e(t,Ee,T)})},K=[100,300],ce=function(e,t){t=t||{},w(function(){var n,r=V(),i=u("FID"),a=function(o){o.startTimethis.unsubscribe(t)}}once(t){let n=this.subscribe((...r)=>{t(...r),n.unsubscribe()});return n}unsubscribe(t){this.listeners.delete(t)}on(t){return this.subscribe(t)}off(t){this.unsubscribe(t)}emit(t){new Set(this.listeners).forEach(n=>n(t))}};function Ce(e){return Array.isArray(e)?e:[e]}var L=class extends y{constructor(t,n,r){super(),this.element=t,this.options=r,this.listener=i=>{this.emit(i)},this.type=Ce(n)}subscribe(t){return this.size===0&&this.type.forEach(n=>{var r;(r=this.element)===null||r===void 0||r.addEventListener(n,this.listener,this.options)}),super.subscribe(t)}unsubscribe(t){super.unsubscribe(t),this.size===0&&this.type.forEach(n=>{var r;(r=this.element)===null||r===void 0||r.removeEventListener(n,this.listener,this.options)})}},I=class extends L{constructor(t,n){let r=typeof window!="undefined"?window:null;super(r,t,n)}},S=class extends L{constructor(t,n){let r=typeof document!="undefined"?document:null;super(r,t,n)}};var p=document.currentScript,B=[{name:"load"}];function ue(){if(B.length>0){let e=p==null?void 0:p.getAttribute("data-api-url"),t=p==null?void 0:p.getAttribute("data-project"),n=p==null?void 0:p.getAttribute("data-page");if(!t||!n){console.warn("The FrontMetrics script was not initialized");return}let r={project:t,page:n,metrics:B};e&&navigator.sendBeacon(e,JSON.stringify(r))&&(B=[])}}function b(e){let t={name:e.name,value:e.value};B.push(t)}var we=new I("pagehide",{capture:!0}),Le=new S("visibilitychange",{capture:!0}),fe=new y;Le.subscribe(()=>{document.visibilityState==="hidden"&&fe.emit()});fe.subscribe(ue);we.subscribe(ue);Z(b);ie(b);re(b);W(b);oe(b);ce(b);})(); //# sourceMappingURL=frontmetrics.min.js.map